package jp.beourselves.open.sample.jdesktop;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

public class JDesktopPaneSample2 {

	private JFrame frmMdi;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JDesktopPaneSample2 window = new JDesktopPaneSample2();
					window.frmMdi.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public JDesktopPaneSample2() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmMdi = new JFrame();
		frmMdi.setTitle("MDI型アプリ サンプル");
		frmMdi.setBounds(100, 100, 450, 400);
		frmMdi.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JDesktopPane desktopPane = new JDesktopPane();
		frmMdi.getContentPane().add(desktopPane, BorderLayout.CENTER);
		
		JInternalFrame frame1 = new JInternalFrame("Frame1");
		frame1.setMaximizable(true);
		frame1.setIconifiable(true);
		frame1.setClosable(true);
		frame1.setBounds(0, 0, 200, 300);
		desktopPane.add(frame1);
		
		JLabel lblHelloJdesktoppane = new JLabel("Hello, JDesktopPane!");
		lblHelloJdesktoppane.setHorizontalAlignment(SwingConstants.CENTER);
		frame1.getContentPane().add(lblHelloJdesktoppane, BorderLayout.CENTER);
		
		JInternalFrame frame2 = new JInternalFrame("Frame2");
		frame2.setBounds(200, 0, 200, 200);
		desktopPane.add(frame2);
		
		JLabel lblHelloJinternalframe = new JLabel("Hello, JInternalFrame");
		lblHelloJinternalframe.setHorizontalAlignment(SwingConstants.CENTER);
		frame2.getContentPane().add(lblHelloJinternalframe, BorderLayout.CENTER);
		frame2.setVisible(true);
		frame1.setVisible(true);
	}
}
